#include "./app_timer.h"
#include "./app_led.h"
#include "./app_can.h"
struct timer_dev_t *sys_timer;
extern struct can_dev_t *comm_dev;//通信设备

uint32_t can_loop_mod_num = 0; 
extern sn_err_t can_app_get_mod_state(struct can_dev_t *dev,uint32_t num);

/*
 *@brief 定时获取模块信息
 */
void can_timer_get_mod(void)
{
      
    if(can_loop_mod_num>=(MAX_MODULE_COUNT-1))can_loop_mod_num = 0;
    else can_loop_mod_num++;
    can_app_get_mod_state(comm_dev,can_loop_mod_num);
    //清除模块在位标志  
}


//can 定时调度函数
void timer_app_sw_can_function(void)
{
  if( comm_dev->initflag !=1)return;
  can_timer_get_mod();
}


void utimer1_500ms_callback(struct timer_dev_t dev,void* param);

void app_timer_init(void)
{
    timer_init(&sys_timer);
    sys_timer->set_inject_callback(sys_timer,utimer1_500ms_callback,0);
		sys_timer->timer_enable();

}

/**
 * @brief 定时器1 500ms 延时函数，对于想要周期性调用的函数应该定义在函数内部
 * 
 */
void utimer1_500ms_callback(struct timer_dev_t dev,void* param)
{
	//appCanCount++;
  timer_app_sw_can_function();
  lamp->timer_callback(lamp);
  comm_dev->can_clear_running_callback(comm_dev);
	
}



